<template>
     <el-tree 
      :data="datamy" 
      show-checkbox
      :props="defaultProps" 
      node-key="id"
      default-expand-all
       ref="tree">
    </el-tree>
</template>
<script>
import { recommended } from '@/api/user';
export default { 
    props:['data'],
    data(){
        return{
        defaultProps: { children: 'children',  label: 'label'},
        id:2,
        expkey:[],
        tree:[],
        datamy:[],
         teep:{vue:2,id:0}
        };
    },
    created() {
       //this.TreeRefresh();
     },
   methods:{
     TreeRefresh(val){
       this.datamy=[];
       this.expkey=[],
       this.teep.id=val;
        recommended(this.teep).then(rsp => {
        if (rsp.errcode === 0) {
           this.datamy=rsp.data;     
           this.expkey = [this.id];     
        }
      });
    },
     getCheckedKeys(){
       this.tree=this.$refs.tree.getCheckedKeys();
       this.$emit('change',this.tree); //返回整个数组
      },
      setCheckedKeys(value) {
      this.$refs.tree.setCheckedKeys(value); 
    }
   }  
}
</script>

